package com.aisb.core.config;

import com.aisb.core.InitParam;
import org.springframework.context.annotation.Configuration;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Configuration
public class ThymeleafStaticConfig {

    @Resource
    private void configureThymeleafStaticVars(ThymeleafViewResolver viewResolver) {
        if(viewResolver != null) {
            Map<String, Object> vars = new HashMap<>();
            vars.put("DEFAULT_PASSWORD", InitParam.DEFAULT_PASSWORD);
            vars.put("SYS_NAME", InitParam.SYS_NAME);
            vars.put("LOGO_URL", InitParam.LOGO_URL);
            vars.put("COPYRIGHT", InitParam.COPYRIGHT);
            viewResolver.setStaticVariables(vars);
        }
    }
}
